<?php
include "config.php";
$array=array();
$base=fopen("data.txt","r");
$category=array('0'=>'graphics','1'=>'mainboard','2'=>'storage','3'=>'raid','4'=>'audio','5'=>'scanner','6'=>'printer','7'=>'modem','8'=>'network','9'=>'input','10'=>'cpu','11'=>'bluetooth','12'=>'portable','13'=>'camera');
$colums=array(0=>'downnum',1=>'category',2=>'fname',3=>'fsize',4=>'test2',5=>'drivername',6=>'company',7=>'fdate',8=>'ver2',9=>'test',10=>'fhash',11=>'alink',12=>'str1',13=>'str2',14=>'str3',15=>'str4',16=>'str5',17=>'str6',18=>'str7',19=>'str8',20=>'str9',21=>'str10',22=>'str11',23=>'str12',24=>'str13');
while (!feof ($base)) {
    $buffer = fgets($base, 4096);

    $array[]=explode("|",$buffer = fgets($base));
}
echo count($array);
$i=0;
$str1="";
$k=0;
while ($k<count($colums)){$str1=$str1.$colums[$k];$k++;if ($k!=count($colums))$str1=$str1.",";}
while($i<count($array))
{
   
    foreach($array as $i=>$str)
    {
        $data="";
      $j=0; 
      
      echo "<br>"; 
      while ($j<count($str)) 
       {  
          
          
          if($j=="1") $data=$data."'".$category[$str[$j]]."'";
          if($j!="1") $data=$data."'".$str[$j]."'";
          if ($j!=count($str)-1)$data=$data.",";
            //echo $str;
            
          $j++;
       }
       $query="INSERT into drivers (".$str1.") VALUES (".$data.")";
      $sql=mysql_query($query);if(!$sql){echo mysql_error($sql);}
    }
    $i++;
}
fclose ($base);
?>